#include "ConstantValue.h"


CType *CConstantValue::GetType() const
{
    switch(Type)
    {
    case EConstantValueType::Bool:
        return CGetType<bool>()();
    case EConstantValueType::Char:
        return CGetType<char32_t>()();
    case EConstantValueType::Int8:
        return CGetType<int8_t>()();
    case EConstantValueType::Int16:
        return CGetType<int16_t>()();
    case EConstantValueType::Int32:
        return CGetType<int32_t>()();
    case EConstantValueType::Int64:
        return CGetType<int64_t>()();
    case EConstantValueType::UInt8:
        return CGetType<uint8_t>()();
    case EConstantValueType::UInt16:
        return CGetType<uint16_t>()();
    case EConstantValueType::UInt32:
        return CGetType<uint32_t>()();
    case EConstantValueType::UInt64:
        return CGetType<uint64_t>()();
    case EConstantValueType::Float:
        return CGetType<float>()();
    case EConstantValueType::Double:
        return CGetType<double>()();
    case EConstantValueType::String:
        return CGetType<CString>()();
    default:
        return nullptr;
    }
}

CAny CConstantValue::ToAny() const
{
    switch (Type)
    {
    case EConstantValueType::Bool:
        return CAny(BoolValue);
    case EConstantValueType::Char:
        return CAny(CharValue);
    case EConstantValueType::Int8:
        return CAny(Int8Value);
    case EConstantValueType::Int16:
        return CAny(Int16Value);
    case EConstantValueType::Int32:
        return CAny(Int32Value);
    case EConstantValueType::Int64:
        return CAny(Int64Value);
    case EConstantValueType::UInt8:
        return CAny(UInt8Value);
    case EConstantValueType::UInt16:
        return CAny(UInt16Value);
    case EConstantValueType::UInt32:
        return CAny(UInt32Value);
    case EConstantValueType::UInt64:
        return CAny(UInt64Value);
    case EConstantValueType::Float:
        return CAny(FloatValue);
    case EConstantValueType::Double:
        return CAny(DoubleValue);
    case EConstantValueType::String:
        return CAny(StringValue);
    default:
        return CAny();
    }
}
